package com.foxire.interface3;

public class ClassDataInterImpl1 implements ClassDatainter{
    private Student[] students;// 存储学生对象信息
    public ClassDataInterImpl1(Student[] students){
        this.students = students;
    }
    @Override
    public void printAllStudentInfos() {
        System.out.println("学生信息如下：");
        for (int i = 0; i < students.length; i++) {
            Student student = students[i];
            System.out.println(student.getName() + " " + student.getScore() + " " + student.getSex());
        }
    }

    @Override
    public void printAverageScore() {
        double sum = 0;
        for (int i = 0; i < students.length; i++){
           Student student = students[i];
           sum += student.getScore();
        }
        System.out.println("平均成绩为："+ sum / students.length);
    }
}
